package com.wx.utils;

import java.util.Arrays;

/**
 * @author DKH
 * @version 1.0.0
 * @ClassName CheckUtil.java
 * @Description TODO
 * @createTime 2021年11月10日 15:25:00
 */
public class CheckUtil {
    private static final String token = "Dkh20020215";
    public static boolean checkSignature(String signature,String timestamp,String nonce){
        String[] str = new String[]{token,timestamp,nonce};
        //排序
        Arrays.sort(str);
        //拼接字符串
        StringBuilder buffer = new StringBuilder();
        for (String s : str) {
            buffer.append(s);
        }
        //进行sha1加密
        String temp = SHA1.encode(buffer.toString());
        //与微信提供的signature进行匹对
        return signature.equals(temp);
    }


}
